﻿
<div ms-controller="tempview" class="ms-controller">
    <div class="sui-container" style="width:98%">
        <div class="sui-form form-inline" style="padding-top:5px;">
            <input type="text" ms-duplex="searchkey" placeholder="关键字搜索" class="input-large input-xfat" />
            <a class="sui-btn btn-large btn-primary" style="margin-left:10px;" ms-click="GetLIST()">查询</a>
            <a style="margin-left:10px;" class="sui-btn btn-large btn-success" ms-click="ADD2('')">添加</a>
        </div>

        <div>
            <table class="sui-table table-primary table-zebra">
                <thead>
                    <tr>
                        <th>标题</th>
                        <th>图片</th>
                        <th>时长</th>
                        <th>免费试听</th>
                        <th>转码状态</th>
                        <th>浏览</th>
                        <th style="width:80px">上传时间</th>
                        <th style="width:120px">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ms-repeat-el="ListData">
                        <td>{{el.Title}}</td>
                        <td><img ms-src="ComFunJS.FilePath(el.ImgUrl,'/50/50')" /></td>
                        <td>{{el.longTime}}</td>
                        <td>
                            <select ms-duplex="el.Free" ms-change="ChangeFree(el)">
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                        </td>
                        <td>{{el.zmzt=='1'?'已转码':'未转码'}}</td>
                        <td>{{el.ViewQty}}</td>
                        <td>{{el.CRTime|date('yyyy-MM-dd')}}</td>
                        <td>
                            <a href="javascript:void(0);" class="sui-btn btn-bordered btn-success" ms-click="ADD2(el)">编辑</a>
                            <a href="javascript:void(0);" class="sui-btn btn-bordered btn-danger" ms-click="DEL2(el)">删除</a>
                        </td>
                    </tr>
                </tbody>
            </table>

            
        </div>

    </div>
</div>

    <script type="text/javascript">
        var tempmodel = avalon.define({
            $id: "tempview",
            searchkey: "",
            HYList:[],
            Type1:"",
            ListData: [],
            ID:"",
            Init: function (id) {
                tempmodel.ID = id;
                tempmodel.GetLIST();
            },
            GetLIST: function (id) {
                model.page.pageindex = 1;
                tempmodel.ListData.clear();
                $.getJSON("/adapi/video/kecheng/" + tempmodel.ID, { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey }, function (r) {
                    if (r.error == "") {
                        tempmodel.ListData = r.result;
                        model.total = r.total;

                        $("#pageDiv").pagination({  //分页容器
                            styleClass: ['sui-pagination'],  //分页样式
                            //showCtrl: false,
                            displayPage: 6,
                            itemsCount: r.total,
                            pageSize: model.page.pagesize,
                            onSelect: function (num) {
                                model.page.pageindex = num;
                                $.getJSON("/adapi/video/kecheng/" + tempmodel.ID, { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey }, function (r) {
                                    tempmodel.ListData.clear();
                                    tempmodel.ListData = r.result;
                                })
                            }
                        })

                        $('#pageDiv').pagination('updateItemsCount', r.total, 1);
                    }
                })
            },
            ADD2: function (el) {
                if (el) {
                    top.ComFunJS.winShowForm("/admin/base/add.html?funcode=video2&ID=" + el.ID + "&infotype=" + el.InfoType, "修改");
                } else {
                    top.ComFunJS.winShowForm("/admin/base/add.html?funcode=video2&infotype=" + model.InfoType + "&InfoID=" + tempmodel.ID, "添加");
                }
            },
            DEL2: function (el) {
                if (el) {
                    top.ComFunJS.winShowConfirm("<span style='color:red;'>确定要删除吗?<span>", function () {
                        $.getJSON("/adapi/video/del/" + el.ID, function (r) {
                            if (r.error == "") {
                                top.ComFunJS.winShowMsg("删除成功");
                                tempmodel.ListData.remove(el);
                            }
                        })
                    })
                }
            },
            ChangeFree: function (el) {
                $.getJSON("/adapi/video/setfree/" + el.ID, function (r) {
                    if (r.error == "") {
                        top.ComFunJS.winShowMsg("设置成功");
                    }
                })


                
            }
        })


    </script>






